package com.edu.exam.entity.examination.paper.technical;

import com.edu.exam.enums.examination.paper.ImageProcessingStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import jakarta.persistence.*;
import java.time.LocalDateTime;

/**
 * 图像处理记录实体类
 *
 * 根据E-04-02图像处理子模块数据库设计实现
 * 存储图像处理的完整记录信息。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class ImageProcessingRecord {

    /**
     * 处理记录ID，主键
     */
    @Id
    @Column(name = "record_id", length = 64)
    private String recordId;

    /**
     * 任务ID
     */
    @Column(name = "task_id", length = 64, nullable = false)
    private String taskId;

    /**
     * 源图像ID
     */
    @Column(name = "source_image_id", length = 64, nullable = false)
    private String sourceImageId;

    /**
     * 原始文件名
     */
    @Column(name = "original_filename", length = 255, nullable = false)
    private String originalFilename;

    /**
     * 处理状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "processing_status", length = 20, nullable = false)
    private ImageProcessingStatus processingStatus;

    /**
     * 处理开始时间
     */
    @Column(name = "processing_start_time", nullable = false)
    private LocalDateTime processingStartTime;

    /**
     * 处理结束时间
     */
    @Column(name = "processing_end_time")
    private LocalDateTime processingEndTime;

    /**
     * 处理耗时（毫秒）
     */
    @Column(name = "processing_duration_ms")
    private Long processingDurationMs;

    /**
     * 来源设备ID
     */
    @Column(name = "source_device_id", length = 64)
    private String sourceDeviceId;

    /**
     * 扫描时间
     */
    @Column(name = "scan_time")
    private LocalDateTime scanTime;

    /**
     * 图像格式
     */
    @Column(name = "image_format", length = 10, nullable = false)
    private String imageFormat;

    /**
     * 原始宽度
     */
    @Column(name = "original_width", nullable = false)
    private Integer originalWidth;

    /**
     * 原始高度
     */
    @Column(name = "original_height", nullable = false)
    private Integer originalHeight;

    /**
     * 原始DPI
     */
    @Column(name = "original_dpi", precision = 5, scale = 1)
    private Double originalDpi;

    /**
     * 文件大小（字节）
     */
    @Column(name = "file_size_bytes", nullable = false)
    private Long fileSizeBytes;

    /**
     * 色彩空间
     */
    @Column(name = "color_space", length = 20)
    private String colorSpace;

    /**
     * 位深度
     */
    @Column(name = "bit_depth")
    private Integer bitDepth;

    /**
     * 压缩比
     */
    @Column(name = "compression_ratio", precision = 5, scale = 2)
    private Double compressionRatio;

    /**
     * 处理配置ID
     */
    @Column(name = "processing_config_id", length = 64)
    private String processingConfigId;

    /**
     * 错误代码
     */
    @Column(name = "error_code", length = 50)
    private String errorCode;

    /**
     * 错误信息
     */
    @Column(name = "error_message", columnDefinition = "TEXT")
    private String errorMessage;

    /**
     * 重试次数
     */
    @Column(name = "retry_count")
    private Integer retryCount;

    /**
     * 创建人
     */
    @Column(name = "created_by", length = 64, nullable = false)
    private String createdBy;

    /**
     * 创建时间
     */
    @Column(name = "created_time", nullable = false)
    private LocalDateTime createdTime;

    /**
     * 更新人
     */
    @Column(name = "updated_by", length = 64)
    private String updatedBy;

    /**
     * 更新时间
     */
    @Column(name = "updated_time")
    private LocalDateTime updatedTime;

    /**
     * 版本号
     */
    @Column(name = "version")
    private Integer version;
}